home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.074 < prev    next >
Encoding:
Text File  |  1989-11-09  |  4.9 KB  |  156 lines  |  [TEXT/pdos]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5.  
  6.  
  7. Apple IIGS
  8. #74:    A Faster List Manager Draw Routine
  9.  
  10. Written by:    Jim Mensch                                       November 1989
  11.  
  12. This Technical Note presents a method for speeding up custom List Draw 
  13. routines, with sample source code for the APW assembler.
  14. _____________________________________________________________________________
  15.  
  16.  
  17. The List Manager is designed to allow users to select from relatively small 
  18. lists.  In this respect, it does quite well.  However, when the width or 
  19. height of the displayed area gets above a certain size (about 20 chars wide 
  20. and 6 items tall) the list starts to scroll slower than normal.  This is due 
  21. to the design of the List Manager's scroll routine.  To scroll text, the List 
  22. Manager calls ScrollRect to scroll the list, then it  redraws all the visible 
  23. members.  On small lists this is fine, but on larger lists it can cause the 
  24. redrawing of much data that is already on the screen, which can take time.  To 
  25. cure this problem, you can include a simple draw procedure in your program 
  26. that checks the clipRgn before anything is drawn.  This way, you will not 
  27. attempt to redraw items that do not need redrawing.
  28.  
  29. The custom draw routine in this Note is an example of one such routine that 
  30. could be used.  It first checks the current clipRgn  (which the List Manager 
  31. was kind enough to shrink down to include only the portion of the list that 
  32. needs redrawing) against the passed item rectangle.  If the rectangle is in 
  33. any way enclosed in the clipRgn, then the member is redrawn; otherwise the 
  34. routine simply returns to the List Manager without drawing.  This sample 
  35. routine is designed to work only with Pascal-style strings, but it can be 
  36. easily modified to use any other type of string you choose.
  37.  
  38. MyListDraw Start
  39. ;
  40. ; This routine draws a list member if any part of the member's
  41. ; rectangle is inside the current clipRgn.
  42. ;
  43. ; Note that the Data Bank register is not defined on entry
  44. ; to this routine.  If you use any absolute addressing, you
  45. ; must set B yourself and restore its value before exiting.
  46. ;
  47. top        equ    0
  48. left       equ    top+2
  49. bottom     equ    left+2
  50. right      equ    bottom+2
  51. rgnBounds  equ    2
  52. ;
  53. oldDPage   equ    1
  54. theRTL     equ    oldDPage+2
  55. listHand   equ    theRTL+3
  56. memPtr     equ    listHand+4
  57. theRect    equ    memPtr+4
  58.            using  globals
  59.  
  60.            phd
  61.            tsc
  62.            tcd
  63.  
  64.            pha
  65.            pha
  66.            _GetClipHandle
  67.            PullLong listHand
  68.  
  69.            ldy    #2
  70.            lda    [listhand],y
  71.            tax
  72.            lda    [listhand]
  73.            sta    listhand
  74.            stx    listhand+2
  75.  
  76.            lda    [therect]         ; now test the top
  77.            dec    a                 ; adjust and give a little slack
  78.            ldy    #rgnbounds+bottom
  79.            cmp    [listhand],y      ; rgnRectBottom>=top?
  80.            blt    skip2
  81.            brl    NoDraw            ; if not don't draw..
  82. Skip2      ldy    #bottom           ; now see if the bottom is higher than
  83.                                     ; the top
  84.            inc    a                 ; give a little slack
  85.            lda    [therect],y
  86.            ldy    #rgnBounds+top
  87.            cmp    [listhand],y
  88.            blt    NoDraw
  89. NoTest    ANOP
  90.  
  91.            PushLong theRect
  92.            _EraseRect               ; erase the old rectangle
  93.  
  94.            ldy    #left
  95.            lda    [theRect],y
  96.            tax
  97.            ldy    #bottom
  98.            lda    [theRect],y
  99.            dec    a
  100.            phx
  101.            pha
  102.            _MoveTo
  103.            ldy    #2
  104.            lda    [memptr],y
  105.            pha
  106.            lda    [memptr]
  107.            pha
  108.            _DrawString
  109.  
  110.            ldy    #4
  111.            lda    [memPtr],y
  112.            and    #$00C0            ; strip to the 6 and 7 bits
  113.            beq    memDrawn          ; if they are both 0 the member is drawn
  114.            cmp    #$0080            ; member selected?
  115.            bne    noSelect          ; member not selectable
  116.            PushLong theRect
  117.            _InvertRect
  118.            bra    memDrawn
  119. ; if we get here the member is disabled
  120. noSelect   PushLong #DimMask
  121.            _SetPenMask
  122.            PushLong theRect
  123.            _EraseRect
  124.            PushLong #NorMask
  125.            _SetPenMask
  126. memDrawn   ANOP
  127.  
  128.  
  129. ; exit here
  130.            pld
  131.            sep    #$20
  132.            longa  off
  133.            pla
  134.            ply
  135.  
  136.            plx
  137.            plx
  138.            plx
  139.            plx
  140.            plx
  141.            plx
  142.            phy
  143.            pha
  144.            rep    #$20
  145.            longa  on
  146.            rtl
  147.  
  148. DimMask    dc     i1'$55,$AA,$55,$AA,$55,$AA,$55,$AA'
  149. NorMask    dc     i1'$FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF'
  150.            end
  151.  
  152.  
  153. Further Reference
  154. _____________________________________________________________________________
  155.     o    Apple IIGS Toolbox Reference, Volumes 1 and 3
  156.